<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">订单</el-breadcrumb-item>
      <el-breadcrumb-item>订单设置</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片组件 -->
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <i class="el-icon-search"></i>
        <span>筛选查询</span>
      </div>
      <!-- 查询表单开始 -->
      <el-form ref="order" :model="form" label-width="80px">
        <el-form-item label="秒杀订单超过:" prop="" label-width="100px">
          <el-input v-model="order.orderTimeout"  placeholder="秒杀订单超过">
            <template slot="append">分</template>
          </el-input>
        </el-form-item>
        <el-form-item label="正常订单超过:" prop="" label-width="100px">
          <el-input v-model="order.seckillTimeout"  placeholder="正常订单超过">
            <template slot="append">分</template>
          </el-input>
        </el-form-item>
        <el-form-item label="发货超过:" prop="" label-width="100px">
          <el-input v-model="order.takeTimeout" placeholder="自动收货（天）">
            <template slot="append">天</template>
          </el-input>
        </el-form-item>
        <el-form-item label="订单完成超过:" prop="" label-width="100px">
          <el-input v-model="order.serviceTimeout" placeholder="订单完成超过">
            <template slot="append">天</template>
          </el-input>
        </el-form-item>
        <el-form-item label="订单完成超过:" prop="" label-width="100px">
          <el-input v-model="order.commentTimeout" placeholder="自动五星好评">
            <template slot="append">天</template>
          </el-input>
        </el-form-item>
        <el-button style="float: right;"  @click="updateOrderConnfig" type="primary">修改</el-button>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  data () {
    return {
      order: {},
      form: {}
    }
  },
  methods: {
    async getAllOrderConfigList () {
      const { data: res } = await this.$http.get(`/orders/orderConfig/findAll`)
      this.order = res[0];
    },
    async updateOrderConnfig () {
      const { data: res} = await this.$http.post(`/orders/orderConfig/update`,this.order)
      if ( res.code !== 200 ) {
        return this.$message.error("修改失败")
      }
      this.$message.success("修改成功")
      this.getAllOrderConfigList()
    }
  },
  async created () {
    this.getAllOrderConfigList()
  }
}
</script>

<style>

</style>